package edu.uic.ids517;

import java.util.Map;

import javax.annotation.PostConstruct;
import javax.faces.context.FacesContext;

public class ActionBeanDatabaseAccess {
	
	private DbaseBean dbase;
	private MessageBean message;
	
	@PostConstruct
	public void init() {
	FacesContext context = FacesContext.getCurrentInstance();
	Map <String, Object> m =
	context.getExternalContext().getSessionMap();
	dbase = (DbaseBean) m.get("dbaseBean");
	message = (MessageBean) m.get("messageBean");
	}
	public String createTables() {
	message.setMessage("");
	message.setErrorMessage("");
	dbase.setQueryType("CREATE");
	//dbase.executeSQL(SQLConstants.CREATE_USER_TABLE);
	return "SUCCESS";
	}
	
	public String dropTables() {
	message.setMessage("");
	message.setErrorMessage("");
	dbase.setQueryType("DROP");
	//dbase.executeSQL(SQLConstants.DROP_USER_TABLE);
	return "SUCCESS";
	}
	
	public String displayTables() {
	message.setMessage("");
	message.setErrorMessage("");
	dbase.setQueryType("SELECT");
	//dbase.executeSQL(SQLConstants.SELECT_USER_TABLE);
	dbase.generateResult();
	return "SUCCESS";
	}
	
	public String importWorksheet(){
		return "SUCCESS";
	}
	
	public String exportWorksheet(){
		return "SUCCESS";
	}

}
